# Loading In Data and Libraries -------------------------------------------
setwd("")
data<-read.csv("02_Clean Racial Shift Full Replication Proprietary.csv")

library(modelsummary)

# Recode
data$educ4 <- NA
data$educ4[which(data$education <= 2)] <- 1 # HS or Less
data$educ4[which(data$education >= 3 & data$education <= 5)] <- 2 # Some college
data$educ4[which(data$education == 6)] <- 3 # College
data$educ4[which(data$education >= 7)] <- 4 # Grad School

data$pid7_nodk <- ifelse(data$political_party_preference < 98, data$political_party_preference, NA)

# Generate Table ----------------------------------------------------------
datasummary_balance(~Treatment, subset(data, select = c("Treatment", "age", "educ4", "gender", "pid7_nodk", "cons_ideo_scale")),
                    # output = "~/desktop/balance.html",
                    fmt = fmt_sprintf("%.2f")
                    )
